<?php

namespace app\index\controller;

use app\index\model\Banner as BannerModel;
use think\Controller;
use think\Request;
use app\index\model\CompanyNews as CompanyNewsModel;
use app\index\model\IndustryNews as IndustryNewsModel;

class News extends BaseController
{
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $banner = BannerModel::getBanner('news');
        $this->assign('banner', $banner);
    }

    /**
     * 企业新闻
     * @return mixed
     */
    public function corporate()
    {
        $news = CompanyNewsModel::getNews();
        $news = $this->changeResponses($news);
        $this->paginate($news->lastPage(), $news->currentPage());
        $this->assign('news', $news);
        return $this->fetch('news_corporate');
    }

    /**
     * 企业新闻详情
     * @return mixed
     */
    public function corporateDetail($id = 0)
    {
        $news = CompanyNewsModel::getById($id);
        $news = $this->changeResponse($news);
        $preId = CompanyNewsModel::getPreId($id);
        $nextId = CompanyNewsModel::getNextId($id);
        $this->assign('preId', $preId);
        $this->assign('nextId', $nextId);
        $this->assign('news', $news);
        return $this->fetch('corporate_detail');
    }

    /**
     * 行业新闻
     * @return mixed
     */
    public function industry()
    {
        $news = IndustryNewsModel::getNews();
        $news = $this->changeResponses($news);
        $this->paginate($news->lastPage(), $news->currentPage());
        $this->assign('news', $news);
        return $this->fetch('news_industry');
    }
    /**
     * 行业新闻详情
     * @return mixed
     */
    public function industryDetail($id = 0)
    {
        $news = IndustryNewsModel::getById($id);
        $news = $this->changeResponse($news);
        $preId = IndustryNewsModel::getPreId($id);
        $nextId = IndustryNewsModel::getNextId($id);
        $this->assign('preId', $preId);
        $this->assign('nextId', $nextId);
        $this->assign('news', $news);
        return $this->fetch('industry_detail');
    }



}
